/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 */
package com.googlecode.ivybeans.module.options;

import java.io.File;
import java.io.IOException;
import org.openide.ErrorManager;

/**
 *
 * @author lforet
 */
public class IvyOptionPanel extends javax.swing.JPanel {

    /** Creates new form IvyOptionPanel */
    public IvyOptionPanel(IvyAdvancedOption ivyOptions) {
        try {
            initComponents();
            File home = ivyOptions.getIvyHome();
            ivyHomeTxt.setText(home.getCanonicalPath());
            setEnabledAllComponents(false);
        } catch (IOException ex) {
            ErrorManager.getDefault().notify(ex);
        }
    }

     private void setEnabledAllComponents(boolean b) {
        ivyHomeLbl.setEnabled(b);
        ivyHomeTxt.setEnabled(b);
        ivyHomeBtn.setEnabled(b);
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        ivyHomeLbl = new javax.swing.JLabel();
        ivyHomeTxt = new javax.swing.JTextField();
        ivyHomeBtn = new javax.swing.JButton();

        ivyHomeLbl.setText(org.openide.util.NbBundle.getMessage(IvyOptionPanel.class, "IvyOptionPanel.ivyHomeLbl.text")); // NOI18N

        ivyHomeTxt.setText(org.openide.util.NbBundle.getMessage(IvyOptionPanel.class, "IvyOptionPanel.ivyHomeTxt.text")); // NOI18N

        ivyHomeBtn.setText(org.openide.util.NbBundle.getMessage(IvyOptionPanel.class, "IvyOptionPanel.ivyHomeBtn.text")); // NOI18N

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(ivyHomeLbl)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(ivyHomeTxt, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 281, Short.MAX_VALUE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(ivyHomeBtn)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(ivyHomeLbl)
                    .add(ivyHomeTxt, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(ivyHomeBtn))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton ivyHomeBtn;
    private javax.swing.JLabel ivyHomeLbl;
    private javax.swing.JTextField ivyHomeTxt;
    // End of variables declaration//GEN-END:variables
}
